package com.qidianit.mes.pro.service.impl;

import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.ProductionOrder;
import com.qidianit.mes.pojo.pro.ProschedueTask;
import com.qidianit.mes.pro.mapper.ProschedueTaskMapper;
import com.qidianit.mes.pro.service.ProschedueTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author: YanJiRan
 * @Date: 2025/9/24 - 下午6:47
 */
@Service
public class ProschedueTaskServiceImpl implements ProschedueTaskService {
    @Autowired
    private ProschedueTaskMapper proschedueTaskMapper;
    @Override
    public Result<List<ProschedueTask>> selectListByWorkflowId(Long id) {
        List<ProschedueTask> proschedueTasks = proschedueTaskMapper.selectListByWorkflowId(id);
        return Result.success(proschedueTasks);
    }

    @Override
    public Result<List<ProschedueTask>> selectList(ProschedueTask proschedueTask) {
        List<ProschedueTask> proschedueTasks = proschedueTaskMapper.selectList(proschedueTask);
        return Result.success(proschedueTasks);
    }

    @Override
    public Result<ProschedueTask> saveProschedueTask(ProschedueTask proschedueTask) {
        return proschedueTaskMapper.saveProschedueTask(proschedueTask) == 1 ? Result.success(proschedueTask) : Result.error("新增工单失败");
    }

    @Override
    public Result<ProschedueTask> selectById(Long id) {
        return Result.success(proschedueTaskMapper.selectById(id));
    }

    @Override
    public Result<ProschedueTask> updateById(ProschedueTask proschedueTask) {
        return proschedueTaskMapper.updateById(proschedueTask) == 1 ? Result.success(proschedueTask) : Result.error("编辑工单失败");
    }

    @Override
    public Result deleteById(Long id) {
        return proschedueTaskMapper.deleteById(id) == 1 ? Result.success() : Result.error("操作失败");
    }

    @Override
    public Result batchDelete(Long[] ids) {
        return null;
    }
}
